<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML,CSS,XML,JavaScript">
<meta name="author" content="Hege Refsnes">
<meta charset="UTF-8">



<?php
require_once './data/users.php';
?>

<?php
session_start();
$_SESSION['uid'] = 1;
?>



<form method="POST">
    <table>

        <tr><td>Username:   <input type="text" name="username"></td></tr>
        <tr><td>Password:   <input type="password" name="password"></td></tr>
        <tr><td><p><input type="checkbox" name="remember">Remember me</p></td></tr>
        <td><input type="submit" name="submit" value="Súp mít"> </td>
    </table>

</form>

<?php if (isset($_POST['submit'])) : ?>
    <?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $isOK = FALSE;
    $index = -1;

    for ($i = 0; $i < count($users); $i++) {
        if ((strcmp($users[$i]['username'], $username) == 0) &&
                (strcmp($users[$i]['password'], $password) == 0)) {
            $isOK = TRUE;
            $index = $i;
        }
    }

    if ($isOK) {
        header("Location:http://localhost:82/huatuonghai-web1/model/db.php?uid=" . $users[$index]['id']);
    } else {
        echo "<script> alert('Khong thanh cong')</script>";
    }
    ?>
<?php endif; ?>
